import 'package:flutter/material.dart';
import 'package:get/get.dart';

void popDialog(Widget body,
    {VoidCallback? onPositiveTap, VoidCallback? onNegativeTap}) {
  Get.dialog(
    Container(
      margin: EdgeInsets.symmetric(
          horizontal: Get.width / 10, vertical: Get.height * 1.1 / 3),
      padding: const EdgeInsets.symmetric(horizontal: 20.0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(5.0),
      ),
      child: Material(
        color: Colors.white,
        child: Column(
          children: [
            Expanded(
              child: body,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                Visibility(
                  visible: onNegativeTap != null,
                  child: GestureDetector(
                    onTap: onNegativeTap,
                    child: const Padding(
                      padding: EdgeInsets.all(8.0),
                      child: Text(
                        '取消',
                        style: TextStyle(
                          fontSize: 16.0,
                          color: Colors.black87,
                        ),
                      ),
                    ),
                  ),
                ),
                const SizedBox(width: 20.0),
                Visibility(
                  visible: onPositiveTap != null,
                  child: GestureDetector(
                    onTap: onPositiveTap,
                    child: const Padding(
                      padding: EdgeInsets.all(8.0),
                      child: Text(
                        '确定',
                        style: TextStyle(
                          fontSize: 16.0,
                          color: Colors.black87,
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
            const SizedBox(height: 10.0),
          ],
        ),
      ),
    ),
  );
}
